<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>仪表板 - 归物</title>

    <!-- 网站图标 -->
    <link rel="icon" type="image/png" href="/icon.png">
    <link rel="shortcut icon" type="image/png" href="/icon.png">
    <link rel="apple-touch-icon" href="/icon.png">

    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <style>
        body {
            background: #f5f7fa;
            min-height: 100vh;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            margin: 0;
            padding: 0;
        }

        .container-fluid {
            padding: 16px;
            max-width: 400px;
            margin: 0 auto;
            padding-bottom: 80px; /* 为底部导航留出空间 */
        }

        /* PC端样式保持不变 */
        @media (min-width: 768px) {
            body {
                background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            }

            .container-fluid {
                padding: 20px;
                padding-bottom: 20px;
            }
        }

        /* 顶部资产卡片 */
        .asset-header {
            background: linear-gradient(135deg, #4285f4 0%, #6366f1 100%);
            border-radius: 20px;
            padding: 20px;
            margin-bottom: 16px;
            color: white;
            box-shadow: 0 4px 20px rgba(66, 133, 244, 0.25);
        }

        .asset-title {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 24px;
        }

        .asset-title h2 {
            font-size: 16px;
            font-weight: 500;
            margin: 0;
            opacity: 0.9;
        }

        .asset-controls {
            display: flex;
            gap: 16px;
            align-items: center;
            font-size: 14px;
        }

        .asset-controls i {
            font-size: 16px;
            opacity: 0.8;
            cursor: pointer;
        }

        .asset-controls span {
            display: flex;
            align-items: center;
            gap: 4px;
        }

        .asset-stats {
            display: flex;
            justify-content: space-between;
            gap: 40px;
        }

        .asset-item {
            flex: 1;
        }

        .asset-label {
            font-size: 13px;
            opacity: 0.7;
            margin-bottom: 8px;
            font-weight: 400;
        }

        .asset-value {
            font-size: 28px;
            font-weight: 600;
            margin: 0;
            line-height: 1.2;
        }

        /* 物品卡片 */
        .item-card {
            background: #4ade80;
            border-radius: 16px;
            padding: 16px 20px;
            margin-bottom: 8px;
            color: white;
            box-shadow: 0 2px 12px rgba(74, 222, 128, 0.15);
            display: flex;
            align-items: center;
            justify-content: space-between;
            transition: all 0.2s ease;
            cursor: pointer;
        }

        .item-card:hover {
            transform: translateY(-1px);
            box-shadow: 0 4px 16px rgba(74, 222, 128, 0.25);
        }

        .item-left {
            display: flex;
            align-items: center;
            gap: 12px;
            flex: 1;
        }

        .item-icon {
            width: 36px;
            height: 36px;
            background: rgba(255, 255, 255, 0.2);
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 16px;
            flex-shrink: 0;
        }

        .item-info {
            flex: 1;
            min-width: 0;
        }

        .item-info h4 {
            font-size: 15px;
            font-weight: 500;
            margin: 0 0 2px 0;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .item-price-info {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 13px;
            opacity: 0.9;
        }

        .item-price {
            font-weight: 600;
        }

        .item-daily {
            font-weight: 400;
        }

        .item-right {
            text-align: right;
            flex-shrink: 0;
        }

        .item-days {
            font-size: 14px;
            font-weight: 500;
            margin: 0;
            opacity: 0.9;
        }

        /* 底部导航 */
        .bottom-nav {
            position: fixed;
            bottom: 0;
            left: 50%;
            transform: translateX(-50%);
            width: 100%;
            max-width: 400px;
            background: white;
            padding: 8px 0 12px 0;
            border-top: 1px solid #e5e7eb;
            display: flex;
            justify-content: space-around;
            box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        }

        .nav-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            color: #9ca3af;
            text-decoration: none;
            font-size: 11px;
            padding: 4px 8px;
            transition: color 0.2s ease;
        }

        .nav-item.active {
            color: #4285f4;
        }

        .nav-item i {
            font-size: 22px;
            margin-bottom: 2px;
        }

        /* 空状态样式 */
        .empty-state {
            text-align: center;
            padding: 60px 20px;
            color: #9ca3af;
        }

        .empty-state i {
            font-size: 48px;
            margin-bottom: 16px;
            opacity: 0.5;
        }

        .empty-state h4 {
            font-size: 18px;
            font-weight: 500;
            margin: 0 0 8px 0;
            color: #6b7280;
        }

        .empty-state p {
            font-size: 14px;
            margin: 0;
            opacity: 0.8;
        }

        /* PC端样式保持原有设计 */
        @media (min-width: 768px) {
            .asset-header {
                background: linear-gradient(135deg, #4285f4 0%, #6366f1 100%);
                border-radius: 20px;
                padding: 24px;
                margin-bottom: 20px;
                box-shadow: 0 8px 32px rgba(66, 133, 244, 0.3);
            }

            .asset-title h2 {
                font-size: 18px;
                font-weight: 600;
            }

            .asset-controls {
                gap: 12px;
            }

            .asset-controls i {
                font-size: 18px;
            }

            .asset-value {
                font-size: 24px;
                font-weight: 700;
            }

            .item-card {
                padding: 20px;
                margin-bottom: 12px;
                box-shadow: 0 4px 16px rgba(74, 222, 128, 0.2);
            }

            .item-card:hover {
                transform: translateY(-2px);
                box-shadow: 0 8px 24px rgba(74, 222, 128, 0.3);
            }

            .item-left {
                gap: 16px;
            }

            .item-icon {
                width: 40px;
                height: 40px;
                font-size: 20px;
            }

            .item-info h4 {
                font-size: 16px;
                font-weight: 600;
                margin-bottom: 4px;
            }

            .item-price-info {
                flex-direction: column;
                align-items: flex-start;
                gap: 2px;
            }

            .item-price-info span:nth-child(2) {
                display: none; /* 隐藏PC端的分隔符 */
            }

            .item-price {
                font-size: 18px;
                font-weight: 700;
            }

            .item-daily {
                font-size: 14px;
                opacity: 0.8;
            }

            .item-days {
                font-size: 16px;
                font-weight: 600;
            }

            .bottom-nav {
                display: none; /* PC端隐藏底部导航 */
            }
        }

        /* 移动端特定样式 */
        @media (max-width: 767px) {
            .container-fluid {
                padding: 16px;
                padding-bottom: 80px;
            }
        }
    </style>
</head>
<body>
    <div class="container-fluid">
        <!-- 顶部资产卡片 -->
        <div class="asset-header">
            <div class="asset-title">
                <h2>我的资产 <span th:text="${items.size()}">13</span>/0</h2>
                <div class="asset-controls">
                    <i class="fas fa-search"></i>
                    <i class="fas fa-sort"></i>
                    <span>全部 <i class="fas fa-chevron-down"></i></span>
                </div>
            </div>
            <div class="asset-stats">
                <div class="asset-item">
                    <div class="asset-label">总资产</div>
                    <div class="asset-value">¥<span th:text="${#numbers.formatDecimal(totalAssets, 1, 2)}">29373.00</span></div>
                </div>
                <div class="asset-item">
                    <div class="asset-label">总日均</div>
                    <div class="asset-value">¥<span th:text="${#numbers.formatDecimal(averageDailyPrice, 1, 2)}">78.23</span></div>
                </div>
            </div>
        </div>

        <div class="items-container">
            <!-- 物品列表 -->
            <div th:if="${#lists.isEmpty(items)}" class="empty-state">
                <i class="fas fa-box-open"></i>
                <h4>暂无物品</h4>
                <p>您还没有添加任何物品</p>
            </div>

            <div th:if="${!#lists.isEmpty(items)}">
                <div th:each="item : ${items}" class="item-card" th:onclick="'showItemDetails(' + ${item.id} + ')'">
                    <div class="item-left">
                        <div class="item-icon">
                            <!-- 根据分类显示不同图标 -->
                            <i th:if="${item.category == '电子产品'}" class="fas fa-laptop"></i>
                            <i th:if="${item.category == '家具'}" class="fas fa-couch"></i>
                            <i th:if="${item.category == '服装'}" class="fas fa-tshirt"></i>
                            <i th:if="${item.category == '书籍'}" class="fas fa-book"></i>
                            <i th:if="${item.category == '运动器材'}" class="fas fa-dumbbell"></i>
                            <i th:if="${item.category == '厨具'}" class="fas fa-utensils"></i>
                            <i th:if="${item.category == '数码配件'}" class="fas fa-headphones"></i>
                            <i th:unless="${#lists.contains({'电子产品','家具','服装','书籍','运动器材','厨具','数码配件'}, item.category)}" class="fas fa-cube"></i>
                        </div>
                        <div class="item-info">
                            <h4 th:text="${item.name}">ARZOPA便携屏</h4>
                            <div class="item-price-info">
                                <span class="item-price">¥<span th:text="${#numbers.formatDecimal(item.price, 1, 2)}">452.00</span></span>
                                <span>•</span>
                                <span class="item-daily">¥<span th:text="${#numbers.formatDecimal(item.dailyPrice, 1, 2)}">2.6</span>/天</span>
                            </div>
                        </div>
                    </div>
                    <div class="item-right">
                        <div class="item-days" th:text="${item.usageDays + '天'}">172天</div>
                    </div>
                </div>
        </div>
    </div>

    <!-- 底部导航栏 -->
    <div class="bottom-nav">
        <a href="/dashboard" class="nav-item active">
            <i class="fas fa-chart-line"></i>
            <span>资产</span>
        </a>
        <a href="/item/add" class="nav-item">
            <i class="fas fa-plus"></i>
            <span>添加</span>
        </a>
        <a href="/profile" class="nav-item">
            <i class="fas fa-user"></i>
            <span>我的</span>
        </a>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <script>
        function showItemDetails(itemId) {
            // 跳转到物品详情页面或编辑页面
            window.location.href = '/item/edit/' + itemId;
        }

        function deleteItem(itemId) {
            if (confirm('确定要删除这个物品吗？')) {
                fetch('/item/delete/' + itemId, {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/x-www-form-urlencoded',
                    }
                }).then(response => {
                    if (response.ok) {
                        window.location.reload();
                    } else {
                        alert('删除失败，请重试');
                    }
                }).catch(error => {
                    console.error('Error:', error);
                    alert('删除失败，请重试');
                });
            }
        }

        // 添加触摸反馈
        document.addEventListener('DOMContentLoaded', function() {
            const itemCards = document.querySelectorAll('.item-card');
            itemCards.forEach(card => {
                card.addEventListener('touchstart', function() {
                    this.style.transform = 'translateY(-1px) scale(0.98)';
                });
                card.addEventListener('touchend', function() {
                    this.style.transform = 'translateY(-2px) scale(1)';
                });
            });
        });
    </script>
</body>
</html> 